package com.ferry.transport.netty.consumer;

import com.ferry.transport.api.ConnectionManager;
import com.ferry.transport.api.Directory;
import com.ferry.transport.api.Transport;
import com.ferry.transport.api.UnResolvedAddress;
import com.ferry.transport.api.channel.WrappedChannelGroup;
import com.ferry.transport.api.config.TcpConfig;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created by daiyong
 */
public interface Connector<T> extends Transport {

	TcpConfig config();

	ConsumerProcessor processor();

	void setProcessor(ConsumerProcessor processor);

	T connect(UnResolvedAddress address);

	T connect(UnResolvedAddress address, boolean async);

	WrappedChannelGroup group(UnResolvedAddress address);

	Collection<WrappedChannelGroup> groups();

	boolean addChannelGroup(Directory directory, WrappedChannelGroup group);

	boolean removeChannelGroup(Directory directory, WrappedChannelGroup group);

	CopyOnWriteArrayList<WrappedChannelGroup> directory(Directory directory);

	boolean isDirectoryAvailable(Directory directory);

	Map<String, CopyOnWriteArrayList<WrappedChannelGroup>> directoryGroup();

	ConnectionManager connectionManager();

	void shutdownGracefully();
}
